package libraryManagerPanels;

import java.awt.Dimension;
import java.awt.Rectangle;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.ListSelectionModel;

import clientGUI.MainGUI;
import clientGUI.PanelDesign;

import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JScrollPane;

public class WatchEmployee extends PanelDesign {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static JTable tableEmp;
	private static JTable tableSub;

	/**
	 * Create the panel.
	 */
	public WatchEmployee() {
		setLayout(null);
		setPreferredSize(new Dimension(644, 462));
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setBounds(3, 3, 638, 456);
		
		JPanel employees=new JPanel();
		tabbedPane.addTab("Employees", employees);
		employees.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Employees List:");
		lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 29));
		lblNewLabel.setBounds(194, 21, 244, 35);
		employees.add(lblNewLabel);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(23, 68, 587, 229);
		employees.add(scrollPane);
		
		tableEmp = new JTable();
		scrollPane.setViewportView(tableEmp);
		
		tableEmp.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  
		tableEmp.setModel(new DefaultTableModel(
				new Object[][] {
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
						{null, null, null,null, null}, {null, null, null, null, null},
			
				},
				new String[] {
					"ID", "First Name" ,"Last Name" , "Phone" , "Email"
				}));
		
		
		
		JPanel subscribers=new JPanel();
		tabbedPane.addTab("Subscribers", subscribers);
		subscribers.setLayout(null);
		
		JScrollPane scrollPane_1 = new JScrollPane();
		scrollPane_1.setBounds(21, 68, 589, 229);
		subscribers.add(scrollPane_1);
		
		
		tableSub = new JTable();
		scrollPane_1.setViewportView(tableSub);
		
		tableSub.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  
		tableSub.setModel(new DefaultTableModel(
				new Object[][] {
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
					{null, null, null,null, null}, {null, null, null, null, null},
			
				},
				new String[] {
					"ID", "First Name" ,"Last Name" , "Phone" , "Email"
				}));
		
		JLabel lblNewLabel_1 = new JLabel("Subscribers List:");
		lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 29));
		lblNewLabel_1.setBounds(189, 25, 254, 32);
		subscribers.add(lblNewLabel_1);
		
		add(tabbedPane);
		remove(background);
		add(background);
		String[] msg=new String[1];
		msg[0]="WatchEmpAndSub";
		MainGUI.OBLClient.handleMessageFromClient(msg);
		JLabel x=new JLabel();
		x.setIcon(background.getIcon());
		x.setBounds(new Rectangle(0, 0, 638, 456));
		JLabel y=new JLabel();
		y.setIcon(background.getIcon());
		y.setBounds(new Rectangle(0, 0, 638, 456));
		employees.add(x);
		subscribers.add(y);
	}
	
	
	
	public static void changeTableContentSubscribers(String[][] x)
	{
		tableSub.setModel(new DefaultTableModel(x,	new String[] {
				"ID", "First Name" ,"Last Name" , "Phone" , "Email"
			}){
		private static final long serialVersionUID = 1L;
		public boolean isCellEditable(int row, int column) {
			return false;
		}
		});
		tableSub.getTableHeader().setReorderingAllowed(false); 
		tableSub.getColumnModel().getColumn(0).setResizable(false);
		tableSub.getColumnModel().getColumn(1).setResizable(false);
		tableSub.getColumnModel().getColumn(2).setResizable(false);
		tableSub.getColumnModel().getColumn(3).setResizable(false);
		tableSub.getColumnModel().getColumn(4).setResizable(false);
		tableSub.getColumnModel().getColumn(4).setPreferredWidth(120);
	}
	
	
	public static void changeTableContentEmployees(String[][] x)
	{
		tableEmp.setModel(new DefaultTableModel(x,	new String[] {
				"ID", "First Name" ,"Last Name" , "Phone" , "Email"
			}){
		private static final long serialVersionUID = 1L;
		public boolean isCellEditable(int row, int column) {
			return false;
		}
		});
		tableEmp.getTableHeader().setReorderingAllowed(false); 
		tableEmp.getColumnModel().getColumn(0).setResizable(false);
		tableEmp.getColumnModel().getColumn(1).setResizable(false);
		tableEmp.getColumnModel().getColumn(2).setResizable(false);
		tableEmp.getColumnModel().getColumn(3).setResizable(false);
		tableEmp.getColumnModel().getColumn(4).setResizable(false);
		tableEmp.getColumnModel().getColumn(4).setPreferredWidth(120);
	}
	
	
	
}
